﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace TPA.DataAccess
{
    public class KeyPoint
    {
        DateTime _DateTimeIn;
        private decimal _AudienceMeasurement,_MarketShare;


        //[Display(ResourceType = typeof(DisplayResources), Name = "LName", Description = "LNameDescription")]
        public string Channel { get; set; }
        public string Label { get; set; }
        public string Date { get { return this.DateTimeIn.Date.ToShortDateString(); } }
        public string TimeIn { get {return this.DateTimeIn.TimeOfDay.ToString(); }}
        public string TimeOut { get { return this.DateTimeOut.TimeOfDay.ToString(); } }
        public decimal AudienceMeasurement 
        {
            get
            {
                return decimal.Round(_AudienceMeasurement, 2, MidpointRounding.AwayFromZero);
            }
            set
            {
                _AudienceMeasurement = value;
            }
        }
        public decimal MarketShare {
            get
            {
                return decimal.Round(_MarketShare, 2, MidpointRounding.AwayFromZero);
            }
            set
        {
            _MarketShare = value;
        }
        }
        public KeyPointType Type { get; set; }
        public DateTime DateTimeIn { get{return _DateTimeIn;} set{_DateTimeIn=value;}}
        public DateTime DateTimeOut { get; set; }
        [DefaultValue(false)]
        public bool Priority { get; set; }

        public override bool Equals(object lkp)
        {
            KeyPoint lkp1 = (KeyPoint)lkp;
            if (this.Label == lkp1.Label && this.DateTimeIn == lkp1.DateTimeIn &&  this.Channel == lkp1.Channel)
                return true;
            else
                return false; 
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }

    public enum KeyPointType
    {
        Program=1, 
        Advertisement=2,
        Tech=3
    }
}
